#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 crane <crane@crane-pc>
#
# Distributed under terms of the MIT license.

"""
orthogonal linked list是有向图的一种表示方式
"""

class ClassStudent:
    def __init__(self, name, stu=None, klass=None):
        self.name = name
        self.right_stu = stu
        self.down_class = klass

def test():
    crane_math_class = ClassStudent('crane_math')
    crane_eng_class = ClassStudent('crane_eng')

    miao_math_class = ClassStudent('miao_math')
    # miao_eng_class = ClassStudent('miao_eng')

    crane_math_class.down_class = crane_eng_class
    crane_math_class.right_stu = miao_math_class

    # 班级/课程 所有学生
    node = crane_math_class
    print('=================== all class students =====================')
    while node:
        print('stu %s ------> ' % node.name, end="")
        node = node.right_stu
    print()
    print()

    # 学生所有课程
    node = crane_math_class
    print("=================== all student's classes =====================")
    while node:
        print('class %s ------> ' % node.name, end ="")
        node = node.down_class
    print()


def main():
    print("start main")
    test()

if __name__ == "__main__":
    main()
